<html>
<head>
<script src="../../build/yahoo/yahoo.js" type="text/javascript"></script>
<script> 

function accumulator() {
    this.sum = 0;
}

accumulator.prototype.add = function(addEnd) { // Adds one number
    this.sum += addEnd;
}

function aggregator() { 
    aggregator.superclass.constructor.apply(this, arguments); 
}

YAHOO.extend(aggregator, accumulator, {
    add: function() { // Adds many numbers
        for (var i = 0; i < arguments.length; i++) {
            aggregator.superclass.add.call(this, arguments[i]);
        }
    }
});


var calculator = new aggregator();
calculator.add(5, 7, 4);
alert(calculator.sum); // Displays "16"
</script>
</head>
<body>
</body>
</html>
